import store from "@/store";
import {checkRouter} from "@/router";

export const WECHAT_AUTH_SCOPE_BASE = 'snsapi_base'
export const WECHAT_AUTH_SCOPE_USERINFO = 'snsapi_userinfo '

/**
 * 跳转微信网页授权链接
 * @param scope 授权参数
 */
export function toAuthUrl(scope, redirectPath, state) {
    // todo gdk
    /*const authUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?' +
        'appid=' + process.env["VUE_APP_WECHAT_APP_ID"] +
        '&redirect_uri=' + encodeURIComponent(store.state.common.currentBaseUrl + redirectUri) +
        '&response_type=code' +
        '&scope=' + scope +
        '&state=' + state +
        '#wechat_redirect`'
    console.log(authUrl)*/

    const url = `${store.state.common.currentBaseUrl}${checkRouter(redirectPath)}?code=${12345678}${state ? '&state=' + state : ''}`
    window.location.replace(url)
}